﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Silverlight.Testing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using XcoAppSpaces.Core;
using System.Threading;
using Microsoft.Ccr.Core;

namespace test.XcoAppSpaces.SL
{
	[TestClass]
	public class LocalIntegrationTests
	{
		[TestMethod]
		public void RunPortAndPostItem()
		{
			using (var space = new XcoAppSpace())
			{
				string result = null;
				var port = space.Run<string>(s => result = s);

				port.Post("test");

				Thread.Sleep(100);

				Assert.AreEqual("test", result);
			}
		}

		[TestMethod]
		public void LocalRequestResponse()
		{
			using (var space = new XcoAppSpace())
			{
				string result = null;
				var responsePort = space.Receive<string>(s => result = s);
				var port = space.Run<Port<string>>(p => p.Post("test"));

				port.Post(responsePort);

				Thread.Sleep(100);

				Assert.AreEqual("test", result);
			}
		}
	}
}